/*
 * Copyright 2010 Mttang.com All right reserved. This software is the
 * confidential and proprietary information of Mttang.com ("Confidential
 * Information"). You shall not disclose such Confidential Information and shall
 * use it only in accordance with the terms of the license agreement you entered
 * into with Mttang.com.
 */
package com.mttang.sys.integration.dao.support;

import java.util.List;
import java.util.Map;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.mttang.sys.dto.UserDTO;
import com.mttang.sys.integration.dao.UserDAO;

/**
 * 类UserDAOImpl.java的实现描述：TODO 类实现描述 
 * @author acc 2010-5-31 下午04:26:37
 */
public class UserDAOImpl extends SqlMapClientDaoSupport implements  UserDAO{

    private Log logger = LogFactory.getLog(getClass());
    /* (non-Javadoc)
     * @see com.mttang.sys.integration.dao.UserDAO#delete(com.mttang.sys.dto.UserDTO)
     */
    @Override
    public void delete(UserDTO dto) {
        // TODO Auto-generated method stub
        if (logger.isInfoEnabled()) {
            logger.info("---UserDAOImpl---delete");
        }
        getSqlMapClientTemplate().delete("SYS.deleteUser", dto);
    }

    /* (non-Javadoc)
     * @see com.mttang.sys.integration.dao.UserDAO#findById(java.lang.Integer)
     */
    @Override
    public UserDTO findById(Integer id) {
        // TODO Auto-generated method stub
        if (logger.isInfoEnabled()) {
            logger.info("---UserDAOImpl---findById");
        }
        return (UserDTO)getSqlMapClientTemplate().queryForObject("SYS.selectUserById", id);
    }

    /* (non-Javadoc)
     * @see com.mttang.sys.integration.dao.UserDAO#findCount(java.util.Map)
     */
    @Override
    public Long findCount(Map<String, Object> param) {
        // TODO Auto-generated method stub
        if (logger.isInfoEnabled()) {
            logger.info("---UserDAOImpl---findCount");
        }
        return (Long)getSqlMapClientTemplate().queryForObject("SYS.countUser", param);
    }

    /* (non-Javadoc)
     * @see com.mttang.sys.integration.dao.UserDAO#findUser(java.util.Map)
     */
    @SuppressWarnings("unchecked")
    @Override
    public List<UserDTO> findUser(Map<String, Object> param) {
        // TODO Auto-generated method stub
        if (logger.isInfoEnabled()) {
            logger.info("---UserDAOImpl---findUser");
        }
        return getSqlMapClientTemplate().queryForList("SYS.selectUser", param);
    }
    
    @SuppressWarnings("unchecked")
    @Override
    public List<Map<String, Object>> findAllUserList(Map<String, Object> param) {
        // TODO Auto-generated method stub
        if (logger.isInfoEnabled()) {
            logger.info("---UserDAOImpl---findUser");
        }
        return getSqlMapClientTemplate().queryForList("SYS.findAllUserList", param);
    }

    /* (non-Javadoc)
     * @see com.mttang.sys.integration.dao.UserDAO#insert(com.mttang.sys.dto.UserDTO)
     */
    @Override
    public void insert(UserDTO dto) {
        // TODO Auto-generated method stub
        if (logger.isInfoEnabled()) {
            logger.info("---UserDAOImpl---insert");
        }
        getSqlMapClientTemplate().insert("SYS.insertUser", dto);
    }

    /* (non-Javadoc)
     * @see com.mttang.sys.integration.dao.UserDAO#login(com.mttang.sys.dto.UserDTO)
     */
    @Override
    public UserDTO login(UserDTO dto) {
        // TODO Auto-generated method stub
        if (logger.isInfoEnabled()) {
            logger.info("---UserDAOImpl---login");
        }
        return (UserDTO)getSqlMapClientTemplate().queryForObject("SYS.login", dto);
    }

    /* (non-Javadoc)
     * @see com.mttang.sys.integration.dao.UserDAO#update(com.mttang.sys.dto.UserDTO)
     */
    @Override
    public void update(UserDTO dto) {
        // TODO Auto-generated method stub
        if (logger.isInfoEnabled()) {
            logger.info("---UserDAOImpl---update");
        }
        getSqlMapClientTemplate().update("SYS.updateUser", dto);
    }

    /* (non-Javadoc)
     * @see com.mttang.sys.integration.dao.UserDAO#findByEmpno(java.lang.String)
     */
    @Override
    public UserDTO findByEmpno(String empno) {
        // TODO Auto-generated method stub
        if (logger.isInfoEnabled()) {
            logger.info("---UserDAOImpl---findById");
        }
        return (UserDTO)getSqlMapClientTemplate().queryForObject("SYS.selectUserByEmpno", empno);
    }

    /* (non-Javadoc)
     * @see com.mttang.sys.integration.dao.UserDAO#updateByEmpno(com.mttang.sys.dto.UserDTO)
     */
    @Override
    public void updateByEmpno(UserDTO dto) {
        // TODO Auto-generated method stub
        if (logger.isInfoEnabled()) {
            logger.info("---UserDAOImpl---updateByEmpno");
        }
        getSqlMapClientTemplate().update("SYS.updateUserByEmpno", dto);
    }

}
